<?php

namespace common\models;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "{{%apply}}".
 *
 * @property integer $id
 * @property string $name
 * @property string $from
 * @property string $email
 * @property string $tel
 * @property integer $status
 * @property integer $weight
 * @property string $created_at
 * @property string $updated_at
 * @property string $res1
 * @property string $res2
 * @property string $res3
 */
class Apply extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public $verifyCode;
    public static function tableName()
    {
        return '{{%apply}}';
    }
    public function behaviors()
    {
        return [
            TimestampBehavior::className(),
        ];
    }
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name', 'from','tel','position','city'], 'required'],
            [['status', 'weight', 'created_at', 'updated_at'], 'integer'],
            [['name', 'from', 'email', 'res1', 'res2', 'res3'], 'string', 'max' => 40],
            [['tel'],  'match','pattern' => '/^1[3-8]{1}[0-9]{1}[0-9]{8}$|189[0-9]{8}$/','message'=>'电话号码有误.'],
            [['tel'], 'unique'],
            [['email'], 'safe'],
            [['position','city'], 'string', 'max' => 40],
            ['verifyCode', 'captcha','on'=>'create'],

        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => '姓名',
            'from' => '公司/组织',
            'email' => '邮箱',
            'tel' => '手机号码',
            'position' => '职位',
            'city' => '城市',
            'status' => 'Status',
            'weight' => 'Weight',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
            'res1' => 'Res1',
            'res2' => 'Res2',
            'res3' => 'Res3',
            'verifyCode' => '验证码',
        ];
    }
}
